#! /usr/bin/env python
from sqlite3 import dbapi2 as sqlite
import sort_history

flist = ["Date", "First", "Second", "Third", "Fourth", "Fifth","Powerball"]

conn = sqlite.connect("lotto-hist")
conn.row_factory = sqlite.Row
curs = conn.cursor()
conn.text_factory = sqlite.OptimizedUnicode

#sort_history.sort_history()

for i in range(1,60):
    number_table = "whiteball_" + str(i)
    draw_row, draw_count = sort_history.get_last_row(number_table)
    #insert select statement to find the draw date from the draw date index table
    #draw_history = curs.execute("select date from
    print str(i) + " was drawn " + str(draw_count) + " times."
    print "Last drawn on " + str(sort_history.get_draw_date(draw_row[0]))

